<template>
	<view class="content">

		<view class="logo">
			<image src="../../../../static/activity/advanced/logo.png" mode=""></image>
		</view>

		<view class="top">
			<image src="../../../../static/activity/advanced/top.png" mode=""></image>
		</view>

		<view class="advanced">
			<view class="" v-for="(item, idx) in advanced" @click="button(item.name, item.id)">
				<view class="advanced01">
					<image :src="item.img" mode=""></image>
				</view>
			</view>
		</view>

		<view class="base">
			<view class="baseImg">
				<image src="../../../../static/activity/advanced/zi.png" mode=""></image>
			</view>
			<view class="baseZi">
				<view>（一）选取时间：2025年2月5日-2月12日</view>
				<view>（二）发放时间：</view>
				<view>柳州本部：2025年3月13日-3月18日，</view>
				<view class="gedang">上午8：30-中午11：30，</view>
				<view class="gedang">下午14：00-下午17：30；</view>
				<view>广西钢铁：2025年3月13日-3月18日，</view>
				<view class="gedang">上午8：00-晚上21：00；</view>
				<view>玉林中金：2025年3月13日-3月18日，</view>
				<view class="gedang">上午8：30-晚上20：00</view>
				<view>（三）发放地点：</view>
				<view>柳州本部：非钢大院雀丰商贸公司发放点；</view>
				<view>广西钢铁：惠享超市（广西钢铁店）；</view>
				<view>玉林中金：惠享超市（玉林中金店）。</view>
				<view>（四）领取方式：</view>
				<view>由各单位统一领取</view>
			</view>
		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				user: null,
				type: null,
				advanced: [{
						id: '228',
						name: '2024年度先进生产(工作)者选择券',
						img: '../../../../static/activity/advanced/01.png',
					},
					{
						id: '229',
						name: '2024年度集团生产(工作)标兵劳动模范选择券',
						img: '../../../../static/activity/advanced/02.png',
					}
				],
				advancedWorker: null,
				advancedWorkModel: null,
			}
		},
		onLoad(opt) {
			uni.showLoading({
				title: '加载中...'
			});
			if (opt.Bearer) {
				uni.setStorageSync("Bearer", opt.Bearer);
				this.bearer();
			} else {
				this.user = uni.getStorageSync("member");
				uni.hideLoading();
				this.advanced_worker();
				this.advanced_work_model();
			}
		},
		methods: {
			bearer() {
				let self = this
				this.$boya.NGet("/app/auth/user", null, function(res) {
					console.log("bearer: ", res);
					self.user = res.data.member;
					uni.setStorageSync("member", res.data.member);
					uni.showToast({
						title: '登录中...',
						duration: 1000,
						icon: 'loading'
					})
					self.advanced_worker();
					self.advanced_work_model();
				}, err => {
					console.log('bearerErr: ', err);
					uni.showToast({
						title: '登录失败,请重试',
						duration: 2000,
						icon: 'error'
					});
				}, false, false)
			},
			advanced_worker() {
				let self = this;
				this.$boya.Request({
					url: '/card_availability',
					data: {
						uuid: self.user.uuid,
						card_name: "2024年度先进生产(工作)者选择券",
					}
				}, function(res) {
					console.log('auditRes: ', res.data);
					if (res.code == 200) {
						if (res.data.status) {
							// res.data.status为1：已审核通过
							// res.data.status为-1：审核不通过通过
							// res.data.status为0：未审核
							if (res.data.status == 1) {
								self.advancedWorker = res.data.type
							}
						}
						uni.hideLoading();
					} else {
						uni.showToast({
							icon: 'error',
							title: res.data
						});
					}
				}, false)
			},
			advanced_work_model() {
				let self = this;
				this.$boya.Request({
					url: '/card_availability',
					data: {
						uuid: self.user.uuid,
						card_name: "2024年度集团生产(工作)标兵劳动模范选择券",
					}
				}, function(res) {
					console.log('auditRes: ', res.data);
					if (res.code == 200) {
						if (res.data.status) {
							// res.data.status为1：已审核通过
							// res.data.status为-1：审核不通过通过
							// res.data.status为0：未审核
							if (res.data.status == 1) {
								self.advancedWorkModel = res.data.type
							}
						}
						uni.hideLoading();
					} else {
						uni.showToast({
							icon: 'error',
							title: res.data
						});
					}
				}, false)
			},
			button(name, id) {
				let self = this
				if (self.advancedWorker == name) {
					uni.navigateTo({
						url: '/pages/activities/welfare/advanced/advanced?id=' + id
					})
				} else if (self.advancedWorkModel == name) {
					uni.navigateTo({
						url: '/pages/activities/welfare/advanced/advanced?id=' + id
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '该账号无 “' + name + '”',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							}
						}
					});
				}
			}
		},
	}
</script>

<style>
	.content {
		width: 100vw;
		height: 100vh;
		background: url('../../../../static/activity/advanced/bj.png') 100% 100% / 100% 100%;
		/* background: linear-gradient(to top, #57785d, #8d9882, #fff); */
	}

	.logo {
		width: 400rpx;
		height: 100rpx;
		margin: 0 auto;
		margin-top: 610rpx;
	}

	.logo>image {
		width: 100%;
		height: 100%;
	}

	.top {
		width: 620rpx;
		height: 90rpx;
		margin: 0 auto;
		margin-top: 50rpx;
	}

	.top>image {
		width: 100%;
		height: 100%;
	}

	.advanced {
		margin-top: 100rpx;
	}

	.advanced01 {
		width: 600rpx;
		height: 200rpx;
		margin: 0 auto;
		margin-top: 70rpx;
	}

	.advanced01>image {
		width: 100%;
		height: 100%;
	}

	.base {
		margin-top: 80rpx;
		background: linear-gradient(to top, #FE1009, #F70F00);
		padding-bottom: 50rpx;
	}

	.baseImg {
		width: 58%;
		height: 48rpx;
		margin: 0 auto;
	}

	.baseImg>image {
		width: 100%;
		height: 100%;
	}

	.baseZi {
		width: 70%;
		margin: 0 auto;
		margin-top: 20rpx;
		padding: 10rpx 50rpx;
		background-color: #FB5736;
		font-weight: bold;
		font-size: 28rpx;
	}

	.gedang {
		text-indent: 4.8em;
	}
</style>